set(FRUDATA_LIB frudata_intf)

find_package(PkgConfig REQUIRED)
pkg_search_module(GLIB REQUIRED glib-2.0)
pkg_search_module(GMODULE REQUIRED gmodule-2.0)

file(GLOB_RECURSE SOURCES "*.c")
add_library(${FRUDATA_LIB} SHARED ${SOURCES})

if (EXISTS "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
    target_include_directories(${FRUDATA_LIB}
        PUBLIC ${LUACLIB_SRC_DIR}
        PUBLIC ${CONAN_INCLUDE_DIRS}
        PUBLIC ${GLIB_INCLUDE_DIRS}
    )
    target_link_libraries(${FRUDATA_LIB}
        PUBLIC ${CONAN_LIBS_HUAWEI_SECURE_C}
        PUBLIC ${GLIB_LIBRARIES}
        PUBLIC ${CONAN_LIBS_LIBMC4LUA}
        PUBLIC logging
        PUBLIC frudata
)
else()
    find_package(libmgmt_protocol REQUIRED)
    find_package(libmc4lua REQUIRED)
    target_include_directories(${FRUDATA_LIB}
        PUBLIC ${GLIB_INCLUDE_DIRS}
    )
    target_link_libraries(${FRUDATA_LIB}
        PUBLIC ${GLIB_LIBRARIES}
        PUBLIC skynet::skynet
        PUBLIC liblogger::liblogger
        PUBLIC libmgmt_protocol::libfrudata
    )
endif()

set_target_properties(${FRUDATA_LIB} PROPERTIES PREFIX "")
install(TARGETS ${FRUDATA_LIB} DESTINATION ${LUACLIB_INSTALL_DIR})
